home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / swanson / strings.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-01-06  |  8.8 KB  |  287 lines

  1. VERSION 2.00
  2. Begin Form Strings 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Strings & Files"
  5.    ClientHeight    =   4650
  6.    ClientLeft      =   1665
  7.    ClientTop       =   3465
  8.    ClientWidth     =   7215
  9.    Height          =   5055
  10.    Left            =   1605
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   4650
  13.    ScaleWidth      =   7215
  14.    Top             =   3120
  15.    Width           =   7335
  16.    Begin CommandButton cmdString 
  17.       Caption         =   "Build outside Loop"
  18.       Height          =   450
  19.       Index           =   1
  20.       Left            =   120
  21.       TabIndex        =   1
  22.       Top             =   1320
  23.       Width           =   1900
  24.    End
  25.    Begin TextBox txtCount2 
  26.       Height          =   280
  27.       Left            =   5700
  28.       TabIndex        =   5
  29.       Text            =   "1000"
  30.       Top             =   2520
  31.       Width           =   1400
  32.    End
  33.    Begin CommandButton cmdFiles 
  34.       Caption         =   "Binary"
  35.       Height          =   450
  36.       Index           =   1
  37.       Left            =   120
  38.       TabIndex        =   3
  39.       Top             =   3840
  40.       Width           =   1900
  41.    End
  42.    Begin CommandButton cmdFiles 
  43.       Caption         =   "Random"
  44.       Height          =   450
  45.       Index           =   0
  46.       Left            =   120
  47.       TabIndex        =   2
  48.       Top             =   3120
  49.       Width           =   1900
  50.    End
  51.    Begin CommandButton cmdString 
  52.       Caption         =   "Build in Loop"
  53.       Default         =   -1  'True
  54.       Height          =   450
  55.       Index           =   0
  56.       Left            =   120
  57.       TabIndex        =   0
  58.       Top             =   660
  59.       Width           =   1900
  60.    End
  61.    Begin TextBox txtCounter 
  62.       Height          =   280
  63.       Left            =   5700
  64.       TabIndex        =   4
  65.       Text            =   "txtCounter"
  66.       Top             =   120
  67.       Width           =   1400
  68.    End
  69.    Begin Label lblFiles 
  70.       BackStyle       =   0  'Transparent
  71.       Caption         =   "00.00 secs"
  72.       FontBold        =   -1  'True
  73.       FontItalic      =   0   'False
  74.       FontName        =   "MS Sans Serif"
  75.       FontSize        =   9.75
  76.       FontStrikethru  =   0   'False
  77.       FontUnderline   =   0   'False
  78.       ForeColor       =   &H00800000&
  79.       Height          =   280
  80.       Index           =   1
  81.       Left            =   5700
  82.       TabIndex        =   8
  83.       Top             =   3840
  84.       Width           =   1400
  85.    End
  86.    Begin Label lblFiles 
  87.       BackStyle       =   0  'Transparent
  88.       Caption         =   "00.00 secs"
  89.       FontBold        =   -1  'True
  90.       FontItalic      =   0   'False
  91.       FontName        =   "MS Sans Serif"
  92.       FontSize        =   9.75
  93.       FontStrikethru  =   0   'False
  94.       FontUnderline   =   0   'False
  95.       ForeColor       =   &H00800000&
  96.       Height          =   280
  97.       Index           =   0
  98.       Left            =   5700
  99.       TabIndex        =   10
  100.       Top             =   3120
  101.       Width           =   1400
  102.    End
  103.    Begin Label Label2 
  104.       BackStyle       =   0  'Transparent
  105.       Caption         =   "Read && Write records using Binary I/O"
  106.       Height          =   450
  107.       Left            =   2150
  108.       TabIndex        =   13
  109.       Top             =   3840
  110.       Width           =   3100
  111.    End
  112.    Begin Label Label1 
  113.       BackStyle       =   0  'Transparent
  114.       Caption         =   "Read && Write records using Random access"
  115.       Height          =   450
  116.       Index           =   4
  117.       Left            =   2150
  118.       TabIndex        =   15
  119.       Top             =   3120
  120.       Width           =   3100
  121.    End
  122.    Begin Label lblTitle 
  123.       AutoSize        =   -1  'True
  124.       BackStyle       =   0  'Transparent
  125.       Caption         =   "File I/O"
  126.       FontBold        =   -1  'True
  127.       FontItalic      =   0   'False
  128.       FontName        =   "MS Sans Serif"
  129.       FontSize        =   12
  130.       FontStrikethru  =   0   'False
  131.       FontUnderline   =   0   'False
  132.       ForeColor       =   &H00800000&
  133.       Height          =   300
  134.       Index           =   2
  135.       Left            =   120
  136.       TabIndex        =   14
  137.       Top             =   2400
  138.       Width           =   1875
  139.    End
  140.    Begin Line Line2 
  141.       BorderColor     =   &H00808080&
  142.       X1              =   0
  143.       X2              =   7335
  144.       Y1              =   2100
  145.       Y2              =   2100
  146.    End
  147.    Begin Label Label1 
  148.       BackStyle       =   0  'Transparent
  149.       Caption         =   "Copy the strings to a temp Variable, then copy temp to new Variable"
  150.       Height          =   450
  151.       Index           =   3
  152.       Left            =   2145
  153.       TabIndex        =   12
  154.       Top             =   1320
  155.       Width           =   3105
  156.    End
  157.    Begin Label Label1 
  158.       BackStyle       =   0  'Transparent
  159.       Caption         =   "Explicitly copy strings to the new Variable"
  160.       Height          =   450
  161.       Index           =   2
  162.       Left            =   2150
  163.       TabIndex        =   11
  164.       Top             =   660
  165.       Width           =   3100
  166.    End
  167.    Begin Label lblString 
  168.       BackStyle       =   0  'Transparent
  169.       Caption         =   "00.00 secs"
  170.       FontBold        =   -1  'True
  171.       FontItalic      =   0   'False
  172.       FontName        =   "MS Sans Serif"
  173.       FontSize        =   9.75
  174.       FontStrikethru  =   0   'False
  175.       FontUnderline   =   0   'False
  176.       ForeColor       =   &H00800000&
  177.       Height          =   280
  178.       Index           =   0
  179.       Left            =   5700
  180.       TabIndex        =   9
  181.       Top             =   660
  182.       Width           =   1400
  183.    End
  184.    Begin Label lblString 
  185.       BackStyle       =   0  'Transparent
  186.       Caption         =   "00.00 secs"
  187.       FontBold        =   -1  'True
  188.       FontItalic      =   0   'False
  189.       FontName        =   "MS Sans Serif"
  190.       FontSize        =   9.75
  191.       FontStrikethru  =   0   'False
  192.       FontUnderline   =   0   'False
  193.       ForeColor       =   &H00800000&
  194.       Height          =   280
  195.       Index           =   1
  196.       Left            =   5700
  197.       TabIndex        =   7
  198.       Top             =   1320
  199.       Width           =   1400
  200.    End
  201.    Begin Label lblTitle 
  202.       AutoSize        =   -1  'True
  203.       BackStyle       =   0  'Transparent
  204.       Caption         =   "Strings"
  205.       FontBold        =   -1  'True
  206.       FontItalic      =   0   'False
  207.       FontName        =   "MS Sans Serif"
  208.       FontSize        =   12
  209.       FontStrikethru  =   0   'False
  210.       FontUnderline   =   0   'False
  211.       ForeColor       =   &H00800000&
  212.       Height          =   300
  213.       Index           =   1
  214.       Left            =   120
  215.       TabIndex        =   6
  216.       Top             =   60
  217.       Width           =   1875
  218.    End
  219.    Begin Line Line1 
  220.       BorderColor     =   &H00FFFFFF&
  221.       BorderWidth     =   2
  222.       Index           =   0
  223.       X1              =   0
  224.       X2              =   7335
  225.       Y1              =   2115
  226.       Y2              =   2115
  227.    End
  228. 'Const Temp = "Begin String......End String"
  229. Sub cmdFiles_Click (Index As Integer)
  230. 'Use Binary instead of Random File I/O"
  231.     On Error Resume Next
  232.     Dim allrecs() As BookAuthor
  233.     ReDim allrecs(txtCount2)
  234.     Me.MousePointer = 11
  235.     For x = 1 To txtCount2
  236.         allrecs(x).ID = x
  237.         allrecs(x).Name = "John Doe - Generic Person"
  238.     Next x
  239.     Kill App.Path & "\" & "files.out"
  240.     If Index = 0 Then
  241.         Open App.Path & "\" & "files.out" For Random As #1
  242.     Else
  243.         Open App.Path & "\" & "files.out" For Binary As #1
  244.     End If
  245.     Start# = Timer
  246.     For x = 1 To txtCount2
  247.        Put #1, , allrecs(x)
  248.     Next x
  249.     Seek #1, 1
  250.     For x = 1 To txtCount2
  251.         Get #1, , allrecs(x)
  252.     Next x
  253.     Finish# = Timer
  254.     lblfiles(Index) = Format(Finish# - Start#, "##.##") & " secs."
  255.     Close #1
  256.     Me.MousePointer = 0
  257. End Sub
  258. Sub cmdString_Click (Index As Integer)
  259.     strfirst$ = "Really long String. "
  260.     strsecond$ = "Next really long string. "
  261.     strthird$ = "I mean this is going to be a really long one!"
  262.     MousePointer = 11
  263.     If Index = 0 Then
  264.         Start# = Timer
  265.         For x = 1 To txtCounter
  266.             result$ = strfirst$ & strsecond$ & strthird$
  267.         Next x
  268.         Finish# = Timer
  269.     Else
  270.         Temp$ = strfirst$ & strsecond$ & strthird$
  271.         Start# = Timer
  272.         For x = 1 To txtCounter
  273.             result$ = Temp$
  274.         Next x
  275.         Finish# = Timer
  276.     End If
  277.     lblString(Index) = Format$(Finish# - Start#, "##.##") & " secs."
  278.     MousePointer = 0
  279. End Sub
  280. Sub Form_Load ()
  281.     ' Center the form
  282.     Me.Left = (screen.Width - Me.Width) / 2
  283.     Me.Top = (screen.Height - Me.Height) / 2
  284.     txtCounter = 10000
  285.     txtCount2 = 1000
  286. End Sub
  287.